package Messages;

import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;

/**
 * This class get Business customers info from the DB 
 * @author Gabi Revah
 * @author Aviad Almog
 */
public class MessagepullBusiness {

	private ConnectionToClient client ;
	private String[] str; 
	
/**
 * Contractor of this class 
	 * @param str
	 * @param client
 */
	public MessagepullBusiness(String[] str, ConnectionToClient client) {
		this.client= client ;
		this.str= str; 	
	}
/**
 * This method pull Business customers from the DB 	
 * @throws SQLException
 * @throws IOException
 */
	public void pullBusiness() throws SQLException, IOException{
		
		SQLConnection sc = new SQLConnection();
		java.sql.PreparedStatement pulbus = sc.getConnection().prepareStatement("SELECT * FROM db.business;");
		ResultSet pulbusrs= pulbus.executeQuery();
		ArrayList<Object> pulbusi=new ArrayList<Object>();
		pulbusi.add("pullBusiness");
		while (pulbusrs.next())
		{
			pulbusi.add(pulbusrs.getString(1));
			pulbusi.add(pulbusrs.getString(2));
			pulbusi.add(pulbusrs.getString(3));
			pulbusi.add(pulbusrs.getString(4));
			pulbusi.add(pulbusrs.getString(5));
			pulbusi.add(pulbusrs.getString(6));
		}
		client.sendToClient(pulbusi);
		
		
		
		
		
		
	}

}
